package kr.co.handysoft.common.profiler;

import kr.co.handysoft.common.compress.Archiving;
import net.sf.json.JSONObject;

import org.hyperic.sigar.Mem;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;

public class MemoryCommand extends AbstractCommand {

	@Override
	public String invoke() {
		
		Sigar sigar = new Sigar();
		
		this.command = "MEMORY";
		
		Mem mem = null;
        try {
            mem = sigar.getMem();
        } catch (SigarException se) {
            se.printStackTrace();
        } finally {
        	sigar.close();
        }
        
        String memInfo = JSONObject.fromObject(mem).toString();
        
		return Archiving.send(memInfo);
		
	}

}
